import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Test27 {
    public int minmumNumberOfHost (int n, int[][] startEnd) {
        int m=startEnd[0].length;
        int left=0,right=1;
        int count=1;
        Map<Integer,Integer> hash=new HashMap<>();
        int[] arr=new int[n];
        int[] brr=new int[n];
        for(int i=0;i<n;i++){
            hash.put(startEnd[i][0],i);
            arr[i]=startEnd[i][0];
        }
        Arrays.sort(arr);
        for(int i=0;i<n;i++){
            brr[i]=startEnd[hash.get(arr[i])][1];
        }
        for(int i=0;i<n;i++){
            startEnd[i][0]=arr[i];
            startEnd[i][1]=brr[i];
        }
        for(int i=1;i<n;i++){
            if(startEnd[i][left] < startEnd[i-1][right]){
                count++;
            }
        }
        return count;
    }










    static int[] dx={0,1,0,-1};
    static int[] dy={1,0,-1,0};

    public static void main02(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int xs = in.nextInt();
        int ys = in.nextInt();
        int xt = in.nextInt();
        int yt = in.nextInt();

        char[][] arr = new char[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            char[] ch = in.next().toCharArray();
            for (int j = 1; j <= m; j++) {

                arr[i][j] = ch[j - 1];
            }
        }
        if (arr[xt][yt] == '*') {
            System.out.println("-1");
        } else {
            int[][] dp=new int[n+1][m+1];
            boolean[][] bool=new boolean[n+1][m+1];
            dfs(arr,dp,xs,ys,bool);
            System.out.println(dp[xt][yt] == 0 ? -1 : dp[xt][yt]);
        }

    }

    public static void dfs(char[][] arr,int[][] dp,int xs,int ys,boolean[][] bool){
        int n=arr.length,m=arr[0].length;
        for(int i=0;i<4;i++){
            int x=xs+dx[i];
            int y=ys+dy[i];
            if(x<n && x>=1 && y<m && y>=1) {
                if (arr[x][y] == '.' && !bool[x][y]) {
                    dp[x][y] = dp[xs][ys] + 1;
                    bool[x][y]=true;
                    dfs(arr, dp, x, y,bool);
                }
            }
        }
    }







    public static void main01(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            int sum=1;
            int count=m;
            while(m != 0){
                if(m % 2 == 0){
                    sum*=n;
                }else{
                    sum*=n-1;
                }
                m--;
            }

            System.out.println(sum);
        }
    }
}
